use actix_web::web;
use serde::{Deserialize,Serialize};

#[derive(Deserialize,Serialize,Debug,Clone,PartialEq)]
pub struct Product {
    pub id: i32,
    pub product_no: i32,
    pub product_type: String,
    pub product_suit_season: String,
    pub product_amount: i32, 
    pub product_name: String,
    pub product_color: String,
    pub product_size: String,
    pub product_price: f64,
    pub product_note: String,
    pub reserve1: String,
    pub reserve2: String,
}

impl From<web::Json<Product>> for Product{
    fn from(product: web::Json<Product>) -> Self{
        Product {
            id : product.id,
            product_no : product.product_no,
            product_type : product.product_type.clone(),
            product_suit_season : product.product_suit_season.clone(),
            product_amount : product.product_amount,
            product_name : product.product_name.clone(),
            product_color : product.product_color.clone(),
            product_size : product.product_size.clone(),
            product_price : product.product_price,
            product_note : product.product_note.clone(),
            reserve1 : product.reserve1.clone(),
            reserve2 : product.reserve2.clone(),
        }
    }
}